'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 公会列表
 * @author sundbcn@gmail.com (sun debing)
 */

var async = require('async');
var _ = require('lodash');
var Code = require('../../../../consts/code');
var unionGroupService = require('../../../../services/unionGroupService');
var unionGroupModel = require('../../../../models/unionGroupModel.js');
var unionGroupConf = require('../../../../config/unionGroupConf.js');

/**
 * 公会列表
 */
module.exports = function (msg, session, next) {
    var role_id = session.uid;
    var union_list = [];

    async.waterfall(
        [
            function (cb) {
                unionGroupModel.getUnionList(cb);
            },
            function (union_list_all, cb) {
                // todo: 只返回所需字段信息
                union_list = union_list_all;
                cb();
            }
        ],
        function (err) {
            if (!!err) {
                console.error(err);
                return next(null, {
                    code: Code.FAIL
                });
            }
            return next(null, {
                code: Code.OK,
                result: {
                    union_list: union_list
                }
            });
        }
    );
};
